import axios from 'axios';
// api
export default {
    data() {
        return {
            data: [],
            // 参数
            params: {
                keyWord: ''
            }
        };
    },
    getTaskInfo(param) {
        this.getParams(param);
        return new Promise(function (resolve, reject) {
            let data = [];
            setTimeout(function () {
                data.push({ id: 1, text: "Project #1", person: '张三', start_date: null, duration: null, parent: 0, progress: .774, open: true });
                if (data.length > 0) {
                    resolve(data)
                } else {
                    reject(data)
                }
            }, 500)
        })    
    },
    editTaskInfoById(id) {
        return new Promise(function (resolve, reject) {
            
            setTimeout(function () {
                let res = {code: 200, msg: '修改成功'};
                if (res) {
                    resolve(res)
                } else {
                    reject(res)
                }
            }, 500)
        })    
    },
    delTaskInfoById(id) {
        return new Promise(function (resolve, reject) {
            
            setTimeout(function () {
                let res = {code: 200, msg: '删除成功'};
                if (res) {
                    resolve(res)
                } else {
                    reject(res)
                }
            }, 500)
        })    
    },


    getParams(param) {
        this.params.keyWord = '';
    },
    async getTaskTreeInGrid() {
        this.data = await getTaskInfo({})
        //TODO
    },
    async getTaskTreeInGantt() {
        this.data = await getTaskInfo({})
        
        //TODO
    },
    async editGridTaskInfoById(id){
        let res = await this.editTaskInfoById('1');
        if (res.code === 200) {
            this.getTaskTreeInGrid();
            //TODO
        }
    },
    async editGanttTaskInfoById(id){
        let res = await this.editTaskInfoById('1');
        if (res.code === 200) {
            this.getTaskTreeInGantt();
            //TODO
        }
    }
}